package com.cssl.api;

import com.cssl.dto.NewUserStatisticsDTO;
import com.cssl.dto.UserCreateDTO;
import com.cssl.entity.User;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.math.BigDecimal;

/**
 * 用户服务对外提供的接口
 */
@FeignClient(name="user-service")
public interface ApiUserLabel {

    /**
     * 用户登陆
     * @param phone
     * @param cipher
     * @return
     */
    @PostMapping("/login")
    public User login(@RequestParam("phone") String phone,
                      @RequestParam("cipher") String cipher);

    /**
     * 创建用户
     * @param userDto
     * @return
     */
    @PostMapping("/createUser")
    @Operation(summary = "创建用户")
    public String createUser(UserCreateDTO userDto);

    /**
     * 余额操作 （带乐观锁）
     * @return
     */
    @PostMapping("/recharge")
    public String recharge(@RequestParam("userId") Integer userId,
                           @RequestParam("amount") BigDecimal amount);

    /**
     * 扣减余额
     * @param userId
     * @param amount
     * @return
     */
    @PostMapping("/deductionMoney")
    public String deductionMoney(@RequestParam("userId") Integer userId,
                                     @RequestParam("amount") BigDecimal amount);

    /**
     * 获取新用户注册数
     * @return
     */
    @PostMapping("/newUserStatistics")
    public NewUserStatisticsDTO newUserStatistics();
}
